import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'
const routes = [
  {
    path: '/',
    component: Layout,
    // redirect:
    children: [
      {
        path: '/',
        component: () => import('@/views/Home')
      },
      {
        path: '/cart',
        component: () => import('@/views/Cart')
      },
      {
        path: '/category/:id', component: () => import('@/views/Category')
      },
      {
        path: '/category/sub/:id', component: () => import('@/views/Category/Sub')
      },
      {
        path: '/goods/:id', component: () => import('@/views/Goods')
      },
      {
        path: '/cart', component: () => import('@/views/Cart')
      },
      {
        path: '/settlement', component: () => import('@/views/Settlement')
      },
      {
        path: '/pay', component: () => import('@/views/Pay')
      },
      {
        path: '/pay/callback', component: () => import('@/views/Pay/callback.vue')
      },
      {
        path: '/member',
        component: () => import('@/views/Member/Layout'),
        children: [
          { path: '/member/', component: () => import('@/views/Member/Home') },
          { path: '/member/order', component: () => import('@/views/Member/Order') }
        ]
      }
    ]
  },
  {
    path: '/playground', component: () => import('@/views/Playground')
  },
  {
    path: '/login',
    component: () => import('@/views/Login')
  },
  {
    path: '/login/callback',
    component: () => import('@/views/Login/callback.vue')
  }
]

// vue2 语法：now vueRouter({routes})
const router = createRouter({
  // 使用hash方式实现路由
  history: createWebHashHistory(),
  // 配置路由规则，写法和之前一样
  routes
})

export default router
